POV-Ray : Newsgroups : povray.general : Random thoughts about povray and xml : Re: Random thoughts about povray and xml Server Time
3 Aug 2024 14:13:19 EDT (-0400)
  Re: Random thoughts about povray and xml  
From: Christopher James Huff
Date: 21 Mar 2004 13:45:12
Message: <cjameshuff-624FE6.13452321032004@news.povray.org>
In article <405dd981$1@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> > Hmm...yes it is. To write "1.5" in a portable way in text only requires
> > writing those three characters. In binary you need to write it byte by
> > byte in a known floating point format and byte ordering, regardless of
> > what the native machine format is.
> 
> This is simply not correct.  You can perfectly represent a floating-point
> number with two integers.  In fact, a floating-point number is exactly that!
> Consequently, representing it as text gains you nothing except the false
> impression that you can get an exact value representation.

Floating point numbers are a bit more than a simple ratio, they are 
usually a binary version of scientific notation. The most common form 
uses a sign bit, a normalized mantissa, and a biased exponent. The 
allocation of individual bits and the actual layout can vary. While the 
text representation may not exactly match the internal value, it will be 
written and read the same way on any platform, which is not guaranteed 
for floating point values in binary files. For that, you must explicitly 
define the layout and write your own code for reading and writing binary 
float values. This isn't very difficult, but it is another step to take.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.